package com.topvision.controller.zwan;

import com.topvision.model.zwan.DeviceCc;
import com.topvision.service.zwan.DeviceCcService;
import com.topvision.util.PageUtils;
import com.topvision.util.Query;
import com.topvision.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 一键呼叫
 *
 * @author shengwm
 * @email 179653076@qq.com
 * @date 2018-01-02 09:49:51
 */
@Api(value = "一键呼叫号码接口", description = "根据BTMAC或系统注册的deviceId获取当前设备对应的呼叫中心的号码")
@RestController
@RequestMapping("devicecc")
public class DeviceCcController  {
    @Autowired
    private DeviceCcService deviceCcService;

    @RequestMapping(value = "/findByMac", method = RequestMethod.POST)
    @ApiOperation(value = "设备蓝牙地址或deviceid", produces = MediaType.APPLICATION_JSON_VALUE, notes = "设备蓝牙地址或deviceid", response = R.class)
    public R findListByParam(@RequestParam String mac){
        Map<String, Object> params = new HashMap<>();
        params.put("deviceid",mac);
        List<DeviceCc> deviceCcList = deviceCcService.queryByParam(params);

        return R.success().put("devicecc", deviceCcList.size() > 0 ? deviceCcList.get(0) : null);
    }



}
